{% extends 'classroom-manage/layout.html.twig' %}

{% block title %}{{'classroom.announcement_manage'|trans}} - {{ parent() }}{% endblock %}
{% set side_nav = 'announcements' %}
{% do script(['app/js/announcement/announcement/index.js'])%}

{% block main %}
  <div class="panel panel-default panel-col">
    <div class="panel-heading">{{'classroom.announcement_manage'|trans}}
      <button class="btn btn-primary btn-sm panel-bar" data-toggle="modal" data-target="#modal" data-url="{{path('announcement_add',{targetId:classroom.id, targetType:'classroom'})}}">{{'announcement.modal_layout.announcement_manage.add_btn'|trans}}</button>
    </div>
    <div class="panel-body">
      <div class="announcement-list">
        {% if announcements %}
          {% for announcement in announcements %}
            <div class="alert alert-default alert-edit clearfix" role="alert">
              <div class="alert-header">
                <i class="icon-click es-icon es-icon-chevronright"></i>
                <span class="title">
              {{ announcement.content|plain_text(40) }}
            </span>

                {% if canManage %}
                  <span class="editor">
                {{ announcement.createdTime|date('Y-m-d') }}
                <a class="mlm" data-target="#modal"  data-toggle="modal" data-url="{{ path('announcement_update',{id:announcement.id, targetType:targetType,  targetId:targetId}) }}"><i class="es-icon es-icon-edit" data-toggle="tooltip" data-placement="top" title="{{'announcement.modal.edit_btn'|trans}}"></i></a>
                <a href="javascript:;" data-role="delete" data-url="{{ path('announcement_delete',{id:announcement.id, targetType:targetType, targetId:targetId}) }}"><i class="es-icon es-icon-delete ml10" data-toggle="tooltip" data-placement="top" title="{{'announcement.modal.delete_btn'|trans}}"></i></a>
              </span>
                {% else %}
                  <span class="data">{{ announcement.createdTime|date('Y-m-d H:i:s') }}</span>
                {% endif %}

              </div>
              <div class="details">
                {{ announcement.content|raw }}
              </div>
            </div>

          {% endfor %}
        {% else %}
          <div class="alert alert-edit" align="center">{{'announcement.empty'|trans}}</div>
        {% endif %}
      </div>
    </div>
  </div>
{% endblock %}